From 55240dbbbdc0fc15aed99f430fece52a00118128 Mon Sep 17 00:00:00 2001 From: "mafetter@fleming.research" Date: Thu, 13 Jan 2005 12:59:47 +0000 Subject: [PATCH] bitkeeper revision 1.1159.220.3 (41e670c37jmaTxUns3KlvsbVRCg-UA) The getdomaininfo hypercall now listens to the exec_domain parameter that was already passed to it, and performs some basic sanity checking. Added exec_domain (aka vcpu) parameters to xc_domain_getfullinfo() and xc_domain_get_cpu_usage(). --- tools/libxc/xc.h | 4 +++- tools/libxc/xc_domain.c | 3 +++ tools/libxc/xc_linux_build.c | 1 + tools/libxc/xc_linux_restore.c | 1 + tools/libxc/xc_linux_save.c | 8 ++++---- tools/libxc/xc_plan9_build.c | 1 + tools/libxc/xc_private.c | 4 +++- tools/libxc/xc_vmx_build.c | 1 + xen/common/dom0_ops.c | 9 ++++++++- 9 files changed, 25 insertions(+), 7 deletions(-) diff --git a/tools/libxc/xc.h b/tools/libxc/xc.h index 3c4d03cfc3..f8276297a1 100644 --- a/tools/libxc/xc.h +++ b/tools/libxc/xc.h @@ -62,13 +62,15 @@ int xc_domain_getinfo(int xc_handle, xc_dominfo_t *info); int xc_domain_getfullinfo(int xc_handle, u32 domid, + u32 vcpu, xc_domaininfo_t *info, full_execution_context_t *ctxt); int xc_domain_setcpuweight(int xc_handle, u32 domid, float weight); long long xc_domain_get_cpu_usage(int xc_handle, - domid_t domid); + domid_t domid, + int vcpu); typedef dom0_shadow_control_stats_t xc_shadow_control_stats_t; diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c index 1d34b3e405..7104ea1a48 100644 --- a/tools/libxc/xc_domain.c +++ b/tools/libxc/xc_domain.c @@ -88,6 +88,7 @@ int xc_domain_getinfo(int xc_handle, { op.cmd = DOM0_GETDOMAININFO; op.u.getdomaininfo.domain = (domid_t)next_domid; + op.u.getdomaininfo.exec_domain = 0; // FIX ME?!? op.u.getdomaininfo.ctxt = NULL; /* no exec context info, thanks. */ if ( do_dom0_op(xc_handle, &op) < 0 ) break; @@ -121,6 +122,7 @@ int xc_domain_getinfo(int xc_handle, int xc_domain_getfullinfo(int xc_handle, u32 domid, + u32 vcpu, xc_domaininfo_t *info, full_execution_context_t *ctxt) { @@ -129,6 +131,7 @@ int xc_domain_getfullinfo(int xc_handle, op.cmd = DOM0_GETDOMAININFO; op.u.getdomaininfo.domain = (domid_t)domid; + op.u.getdomaininfo.exec_domain = (u16)vcpu; op.u.getdomaininfo.ctxt = ctxt; rc = do_dom0_op(xc_handle, &op); diff --git a/tools/libxc/xc_linux_build.c b/tools/libxc/xc_linux_build.c index 0932f5cacf..e155c1feb4 100644 --- a/tools/libxc/xc_linux_build.c +++ b/tools/libxc/xc_linux_build.c @@ -370,6 +370,7 @@ int xc_linux_build(int xc_handle, op.cmd = DOM0_GETDOMAININFO; op.u.getdomaininfo.domain = (domid_t)domid; + op.u.getdomaininfo.exec_domain = 0; op.u.getdomaininfo.ctxt = ctxt; if ( (do_dom0_op(xc_handle, &op) < 0) || ((u16)op.u.getdomaininfo.domain != domid) ) diff --git a/tools/libxc/xc_linux_restore.c b/tools/libxc/xc_linux_restore.c index d7ed2d6776..8909878f81 100644 --- a/tools/libxc/xc_linux_restore.c +++ b/tools/libxc/xc_linux_restore.c @@ -177,6 +177,7 @@ int xc_linux_restore(int xc_handle, XcIOContext *ioctxt) /* Get the domain's shared-info frame. */ op.cmd = DOM0_GETDOMAININFO; op.u.getdomaininfo.domain = (domid_t)dom; + op.u.getdomaininfo.exec_domain = 0; op.u.getdomaininfo.ctxt = NULL; if ( do_dom0_op(xc_handle, &op) < 0 ) { diff --git a/tools/libxc/xc_linux_save.c b/tools/libxc/xc_linux_save.c index 9522446736..9d07efe158 100644 --- a/tools/libxc/xc_linux_save.c +++ b/tools/libxc/xc_linux_save.c @@ -232,8 +232,8 @@ static int print_stats( int xc_handle, u32 domid, gettimeofday(&wall_now, NULL); - d0_cpu_now = xc_domain_get_cpu_usage( xc_handle, 0 )/1000; - d1_cpu_now = xc_domain_get_cpu_usage( xc_handle, domid )/1000; + d0_cpu_now = xc_domain_get_cpu_usage( xc_handle, 0, /* FIXME */ 0 )/1000; + d1_cpu_now = xc_domain_get_cpu_usage( xc_handle, domid, /* FIXME */ 0 )/1000; if ( (d0_cpu_now == -1) || (d1_cpu_now == -1) ) printf("ARRHHH!!\n"); @@ -331,7 +331,7 @@ int suspend_and_state(int xc_handle, XcIOContext *ioctxt, retry: - if ( xc_domain_getfullinfo(xc_handle, ioctxt->domain, info, ctxt) ) + if ( xc_domain_getfullinfo(xc_handle, ioctxt->domain, /* FIXME */ 0, info, ctxt) ) { xcio_error(ioctxt, "Could not get full domain info"); return -1; @@ -444,7 +444,7 @@ int xc_linux_save(int xc_handle, XcIOContext *ioctxt) return 1; } - if ( xc_domain_getfullinfo( xc_handle, domid, &info, &ctxt) ) + if ( xc_domain_getfullinfo( xc_handle, domid, /* FIXME */ 0, &info, &ctxt) ) { xcio_error(ioctxt, "Could not get full domain info"); goto out; diff --git a/tools/libxc/xc_plan9_build.c b/tools/libxc/xc_plan9_build.c index 819969c57d..f319809716 100755 --- a/tools/libxc/xc_plan9_build.c +++ b/tools/libxc/xc_plan9_build.c @@ -467,6 +467,7 @@ xc_plan9_build(int xc_handle, op.cmd = DOM0_GETDOMAININFO; op.u.getdomaininfo.domain = (domid_t) domid; + op.u.getdomaininfo.exec_domain = 0; op.u.getdomaininfo.ctxt = ctxt; if ((do_dom0_op(xc_handle, &op) < 0) || ((u32) op.u.getdomaininfo.domain != domid)) { diff --git a/tools/libxc/xc_private.c b/tools/libxc/xc_private.c index cbf42cc68f..65aa1085e0 100644 --- a/tools/libxc/xc_private.c +++ b/tools/libxc/xc_private.c @@ -160,12 +160,13 @@ int finish_mmu_updates(int xc_handle, mmu_t *mmu) } -long long xc_domain_get_cpu_usage( int xc_handle, domid_t domid ) +long long xc_domain_get_cpu_usage( int xc_handle, domid_t domid, int vcpu ) { dom0_op_t op; op.cmd = DOM0_GETDOMAININFO; op.u.getdomaininfo.domain = (domid_t)domid; + op.u.getdomaininfo.exec_domain = (u16)vcpu; op.u.getdomaininfo.ctxt = NULL; if ( (do_dom0_op(xc_handle, &op) < 0) || ((u16)op.u.getdomaininfo.domain != domid) ) @@ -248,6 +249,7 @@ long xc_get_tot_pages(int xc_handle, u32 domid) dom0_op_t op; op.cmd = DOM0_GETDOMAININFO; op.u.getdomaininfo.domain = (domid_t)domid; + op.u.getdomaininfo.exec_domain = 0; op.u.getdomaininfo.ctxt = NULL; return (do_dom0_op(xc_handle, &op) < 0) ? -1 : op.u.getdomaininfo.tot_pages; diff --git a/tools/libxc/xc_vmx_build.c b/tools/libxc/xc_vmx_build.c index 58f31cd797..85de2a3f97 100644 --- a/tools/libxc/xc_vmx_build.c +++ b/tools/libxc/xc_vmx_build.c @@ -430,6 +430,7 @@ int xc_vmx_build(int xc_handle, op.cmd = DOM0_GETDOMAININFO; op.u.getdomaininfo.domain = (domid_t)domid; + op.u.getdomaininfo.exec_domain = 0; op.u.getdomaininfo.ctxt = ctxt; if ( (do_dom0_op(xc_handle, &op) < 0) || ((u16)op.u.getdomaininfo.domain != domid) ) diff --git a/xen/common/dom0_ops.c b/xen/common/dom0_ops.c index f23bbfd14e..b52576f857 100644 --- a/xen/common/dom0_ops.c +++ b/xen/common/dom0_ops.c @@ -354,7 +354,14 @@ long do_dom0_op(dom0_op_t *u_dom0_op) op->u.getdomaininfo.domain = d->id; - ed = d->exec_domain[0]; // op->u.getdomaininfo.exec_domain]; + if ( (op->u.getdomaininfo.exec_domain >= MAX_VIRT_CPUS) || + !d->exec_domain[op->u.getdomaininfo.exec_domain] ) + { + ret = -EINVAL; + break; + } + + ed = d->exec_domain[op->u.getdomaininfo.exec_domain]; op->u.getdomaininfo.flags = (test_bit( DF_DYING, &d->d_flags) ? DOMFLAGS_DYING : 0) | -- 2.30.2